import java.util.EmptyStackException;

public class MyQueue {
    public static class Node
    {
        public int val;
        public Node next;

        public Node(int val) {
            this.val = val;
        }
    }

    public Node head;
    public Node last;
    public int usesize;

    public void offer(int val)
    {
        Node node =new Node(val);
        if(head==null)
        {
            head=node;
            last=node;
        }
        else
        {
            last.next=node;
            last=node;
        }
        usesize++;
    }

    public int poll()
    {
        if(isEmpty())
        {
            throw new EmptyException("为空！！！");
        }
        int num=head.val;
        head=head.next;
        if(head==null)
        {
            last=null;
        }
        usesize--;
        return num;
    }
    public boolean isEmpty()
    {
        return usesize==0;
    }


    public boolean Empty()
    {
        return usesize==0;
    }


    public int peek()
    {
        if(isEmpty())
        {
            throw new EmptyException("为空！！！");
        }

        return head.val;
    }
}
